import { formatTimestamp } from '@/settings'
import { getToken } from '@/utils/auth'

const defaultSettings = require('@/settings.js')

export default (_self) => {
  return {
    editBtn: true,
    menu: false,
    delBtn: true,
    addBtn: false,
    labelWidth: 140,
    index: true,
    indexLabel: '序号',
    align: 'center',
    headerAlign: 'center',
    border: true,
    dialogWidth: '50%',
    stripe: false,
    searchShow: false,
    searchShowBtn: false,
    size: 'mini',
    // excelBtn: true,
    // selection: true,
    searchMenuSpan: 4,
    props: {
      label: 'label',
      value: 'value'
    },
    column: [
      {
        label: '所属项目',
        prop: 'chargeId',
        type: 'select',
        dicHeaders: {
          Authorization: getToken()
        },
        dicUrl: `${defaultSettings.baseUrl}/charge/list`,
        props: {
          label: 'name',
          value: 'id',
          res: 'data'
        },
        rules: [
          {
            required: true,
            message: '请选择',
            trigger: 'blur'
          }
        ]
      },
      {
        prop: 'userinfo',
        label: '用户信息',
        children: [

          {
            prop: 'avatarUrl',
            type: 'img',
            label: '头像'
          },
          {
            prop: 'nickName',
            label: '昵称'
          },
          {
            prop: 'mobile',
            label: '手机号'
          }

        ]
      },
      {
        prop: 'sin',
        hide: true,
        label: '签名'
      },
      {
        prop: 'price',
        label: '价格'
      },
      {
        prop: 'effectDays',
        label: '有效天数'
      },
      {
        label: '状态',
        prop: 'status',
        search: true,
        display: false,
        type: 'select',
        dicData: [
          {
            value: 0,
            label: '不可用'
          },
          {
            value: 1,
            label: '可用'
          },
          {
            value: 2,
            label: '已使用'
          }
        ],
        rules: [
          {
            required: true,
            message: '请输入',
            trigger: 'blur'
          }
        ]
      },
      {
        label: '添加时间',
        prop: 'createTime',
        searchRange: true,
        type: 'datetime',
        addDisplay: false,
        editDisplay: false,
        display: false,
        formatter: (row, val) => {
          return formatTimestamp(val)
        },
        rules: [
          {
            required: true,
            message: '请输入',
            trigger: 'blur'
          }
        ]
      }
    ]
  }
}
